= render partial: 'toolbar_upload_img', locals: {text_id: 'article_content'}

= form_for @article, role: 'form' do |f|
  .form-group
    %label{for: 'article_title'} 文章标题
    = f.text_field :title, placeholder: '文章标题', class: 'form-control'
  .form-group
    %label{for: 'article_category_id'} 文章分类
    = select_tag "article[category_id]", options_for_select(get_categories_options, @article.category_id), include_blank: true, class: 'form-control'
    或者新建一个分类：
    = f.text_field :category_name, placeholder: '分类名称', class: 'form-control'
  .form-group
    %label{for: 'article_tags'} 标签
    = f.text_field :tags, placeholder: '文章标签，多个用英文“,”隔开', class: 'form-control'
  .form-group
    %label{for: 'article_source'} 文章来源
    = f.text_field :source, placeholder: '文章来源，为空则为原创', class: 'form-control'
  .form-group
    %ul.nav.nav-tabs#preview_tab{role: "tablist"}
      %li.active
        = link_to '文章内容', '#edit', role: 'tab', 'data-toggle'=>'tab'
      %li
        = link_to '预览', '#preview', role: 'tab', 'data-toggle'=>'tab'
    .tab-content
      .tab-pane.active#edit
        = f.text_area :content, placeholder: '文章内容', class: 'form-control'
      .tab-pane#preview
  .form-group
    = f.submit '提交', class: 'btn btn-success btn-lg btn-block'

:javascript
  $(function(){
    $('#preview_tab a[href="#preview"]').click(function(e){
      e.preventDefault();
      $(this).tab('show');
      preview('article_content', 'preview');
    });
  });

